
/**
 * @ProjectName: 
 * @Copyright: 2014 lisheng Co.; Ltd. All Right Reserved.
 * @address: toughheart@163.com
 * @date: 2015年9月25日 下午8:29:33
 * @Description: 本内容未经本人允许禁止使用、转发.
 */
 
package com.ls.fw.mvc.springmvc.support.freemaker.bean;

import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;


/**
 * 
 * @author lisheng
 * @date 2015年9月25日 下午8:29:33
 * @version V1.0 
 */
public class GenControllerPara {

	private String entityPackage;
	private String entityName;
	private String voPackage;
	private String voName;
	private String formPackage;
	private String formName;
	private String pkFullName; 
	private String user;
	private String templateDir;
	private String templateName;
	private String serviceName;
	private String servicePackage;
	private String serviceParaName;
	private String controllerName;
	private String controllerPackage;
	private String srcDir = "src/main/java";
	private boolean gen = true;
	private String mappingValue = "";
	private Set<String> entityMap = new HashSet<String>();
	
	public Set<String> getEntityMap(){
		return this.entityMap;
	} 
	public GenControllerPara addEntity(String cla){
		this.entityMap.add(cla);
		return this;
	}
	 
	public String getEntityPackage() {
		return this.entityPackage;
	}
	public void setEntityPackage(String entityPackage) {
		this.entityPackage = entityPackage;
	}
	public String getEntityName() {
		return this.entityName;
	}
	public void setEntityName(String entityName) {
		this.entityName = entityName;
	}
	public String getVoPackage() {
		if(StringUtils.isBlank(voPackage)&&StringUtils.isNotBlank(getBasePackage())){
			voPackage = this.getBasePackage()+".vo";
		}
		return this.voPackage;
	}
	
	protected String getBasePackage(){
		if(entityPackage==null){
			return "";
		}
		int index = entityPackage.lastIndexOf(".");
		return entityPackage.substring(0, index);
	}
	
	public void setVoPackage(String voPackage) {
		this.voPackage = voPackage;
	}
	public String getVoName() {
		if(StringUtils.isBlank(voName)&&StringUtils.isNotBlank(getEntityName())){
			voName = this.getEntityName()+"Vo";
		}
		return this.voName;
	}
	public void setVoName(String voName) {
		this.voName = voName;
	}
	public String getPkFullName() {
		return this.pkFullName;
	}
	public void setPkFullName(String pkFullName) {
		this.pkFullName = pkFullName;
	}
	 
	public String getUser() {
		if(StringUtils.isBlank(user)){
			user = "ls";
		}
		return this.user;
	}
	public void setUser(String user) {
		this.user = user;
	}
	public String getTemplateDir() {
		return this.templateDir;
	}
	public void setTemplateDir(String templateDir) {
		this.templateDir = templateDir;
	}
	public String getTemplateName() {
		return this.templateName;
	}
	public void setTemplateName(String templateName) {
		this.templateName = templateName;
	}
	 
	public String getSrcDir() {
		return srcDir;
	}
	public void setSrcDir(String srcDir) {
		this.srcDir = srcDir;
	}
	 
	public boolean isGen() {
		return gen;
	}
	public void setGen(boolean gen) {
		this.gen = gen;
	} 
	public String getServiceName() {
		if(StringUtils.isBlank(serviceName)
				&&StringUtils.isNotBlank(getEntityName())){
			serviceName = this.getEntityName()+"Service";
		}
		return this.serviceName;
	}
	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}
	public String getServicePackage() {
		if(StringUtils.isBlank(servicePackage)&&StringUtils.isNotBlank(getBasePackage())){
			servicePackage = this.getBasePackage()+".service";
		}
		return this.servicePackage;
	}
	public void setServicePackage(String servicePackage) {
		this.servicePackage = servicePackage;
	} 
	public String getMappingValue() {
		if(StringUtils.isBlank(mappingValue)&&StringUtils.isNotBlank(getEntityName())){
			String paraName = this.getEntityName().substring(0,1).toLowerCase()+this.getEntityName().substring(1);
			mappingValue = "/"+paraName;
		}
		return mappingValue;
	}
	public void setMappingValue(String mappingValue) {
		this.mappingValue = mappingValue;
	}
	public String getControllerName() {
		if(StringUtils.isBlank(controllerName)&&StringUtils.isNotBlank(getEntityName())){
			controllerName = this.getEntityName()+"Controller";
		}
		return controllerName;
	}
	public void setControllerName(String controllerName) {
		this.controllerName = controllerName;
	}
	public String getControllerPackage() {
		return controllerPackage;
	}
	public void setControllerPackage(String controllerPackage) {
		this.controllerPackage = controllerPackage;
	}
	public String getServiceParaName() {
		if(StringUtils.isBlank(serviceParaName)&&StringUtils.isNotBlank(getServiceName())){
			String paraName = this.getServiceName().substring(0,1).toLowerCase()+this.getServiceName().substring(1);
			serviceParaName = paraName;
		}
		return serviceParaName;
	}
	public void setServiceParaName(String serviceParaName) {
		this.serviceParaName = serviceParaName;
	}
	public String getFormPackage() {
		return this.formPackage;
	}
	public void setFormPackage(String formPackage) {
		this.formPackage = formPackage;
	}
	public String getFormName() {
		return this.formName;
	}
	public void setFormName(String formName) {
		this.formName = formName;
	}
}
